<!DOCTYPE html>
<html dir="ltr" mozdisallowselectionprint>
	<head>
		<meta charset="utf-8">
		<title>预览txt</title>
		<script src="./utils/flexible.js"></script>
		<script src="./utils/getQueryVariable.js"></script>
	</head>
	
	<style type="text/css">
		*{padding: 0;margin: 0;}
		body {
			height: 100vh;
			width: 100vw;
		}
		#container {
			width: 100%;
			height: 100%;
			font-size: 0.28rem;
		}
	</style>
	
	<script>
		
		function fetchBlobFromUrl(blobUrl) {
		  return new Promise((resolve, reject) => {
		    const xhr = new XMLHttpRequest();
		    xhr.open('GET', blobUrl, true);
		    xhr.responseType = 'blob';
		    xhr.onload = function () {
		      if (xhr.status === 200) {
		        resolve(xhr.response);
		      } else {
		        reject(new Error(`Failed to fetch blob: ${xhr.statusText}`));
		      }
		    };
		    xhr.onerror = function (err) {
		      reject(new Error(err));
		    };
		    xhr.send();
		  });
		}

	    
		(async function () {
			const fileUrl = decodeURIComponent(getQueryVariable('file') || '')
			const blob = await fetchBlobFromUrl(fileUrl);
			console.log('txt', blob)
			const reader = new FileReader();
			reader.onload = () => {
				// console.log('reader.result', reader.result)
				document.getElementById('container').innerHTML = reader.result
			};
			reader.readAsText(blob);
		}())
	</script>
	
	<body id="body">
		<pre id="container"></pre>
	</body>
	
	
	
</html>

